﻿using Shop.RemoteModel.Activity.Model;
using Shop.StoreGatewayModular.Interface;
using Shop.StoreGatewayModular.Linq;
using Shop.StoreGatewayModular.Model.Activity;
using WeDonekRpc.ApiGateway.Attr;
using WeDonekRpc.Client;
using WeDonekRpc.Helper.Validate;
using WeDonekRpc.HttpApiGateway;
using WeDonekRpc.HttpApiGateway.Model;

namespace Shop.StoreGatewayModular.Api
{
    [ApiRouteName("/shop/activity/{name}")]
    internal class ActivityApi : ApiController
    {
        private readonly IActivityService _Activity;

        public ActivityApi ( IActivityService activity )
        {
            this._Activity = activity;
        }
        public ActivityBase[] Gets ( [NullValidate("shop.activity.id.null")][NumValidate("shop.activity.id.error", 1)] long[] ids )
        {
            return this._Activity.Gets(ids);
        }
        /// <summary>
        /// 新增活动
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public long Add ( ActivityAdd data )
        {
            return this._Activity.Add(data);
        }
        /// <summary>
        /// 获取活动详细
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActivityDetailedDto GetDetailed ( [NumValidate("shop.activity.id.error", 1)] long id )
        {
            return this._Activity.GetDetailed(id);
        }
        /// <summary>
        /// 删除活动
        /// </summary>
        /// <param name="id"></param>
        public void Delete ( [NumValidate("shop.activity.id.error", 1)] long id )
        {
            this._Activity.Delete(id);
        }
        /// <summary>
        /// 获取活动
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActivityData Get ( [NumValidate("shop.activity.id.error", 1)] long id )
        {
            return this._Activity.Get(id);
        }
        /// <summary>
        /// 下架活动
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool OffShelf ( [NumValidate("shop.activity.id.error", 1)] long id )
        {
            return this._Activity.OffShelf(id);
        }
        /// <summary>
        /// 查询活动列表
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public PagingResult<ActivityBase> Query ( PagingParam<ActivityQueryParam> query )
        {
            return this._Activity.Query(query);
        }
        /// <summary>
        /// 修改活动
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public bool Set ( LongParam<ActivitySet> param )
        {
            return this._Activity.Set(param.Id, param.Value);
        }
        /// <summary>
        /// 提交审核
        /// </summary>
        /// <param name="id"></param>
        public void SubmitAudit ( [NumValidate("shop.activity.id.error", 1)] long id )
        {
            this._Activity.SubmitAudit(id);
        }
        /// <summary>
        /// 审核通过
        /// </summary>
        /// <param name="id"></param>
        public bool AuditPass ( [NumValidate("shop.activity.id.error", 1)] long id )
        {
            return this._Activity.AuditPass(id, base.UserState.ToUserId());
        }
        /// <summary>
        /// 审核通过
        /// </summary>
        /// <param name="id"></param>
        public bool AuditNoPass ( LongParam<string> param )
        {
            return this._Activity.AuditNoPass(param.Id, base.UserState.ToUserId(), param.Value);
        }
    }
}
